package net.lzzy.twocarsort;

import org.apache.spark.sql.AnalysisException;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class SQlMaxMinSex {
    public static void main(String[] args) throws AnalysisException {
        SparkSession local = SparkSession.builder()
                .appName(SQlMaxMinSex.class.getName())
                .master("local")
                .getOrCreate();

        Dataset<Row> json = local.read().json("src/student.json");
        json.createTempView("student");

        Dataset<Row> sql = local.sql("select institute,sex,max(age),min(age) from student group by institute,sex ");
        sql.show();
    }
}
